<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:include="inc/home::header">
</head>

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body, html {
	overflow-y: auto;
	background: #fff
}
</style>
<body>
	<div class="project-view">
		<form id="userForm">
		
			<input type="text"  readonly="readonly"  style="display: none" name="id"  /> 
			<input type="text"  readonly="readonly"  style="display: none" name="roleName"  /> 
			<table width="100%" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td width="18%" align="right"><span class="color-red">*</span>用户名称：</td>
					<td width="82%"><textarea  name="userName"
							placeholder="输入用户名称，若同时添加多个用户，请以回车换行隔开" style="height: 60px"
							class="textarea-pub"></textarea></td>
				</tr>
				<tr>
					<td align="right"><span class="color-red">*</span>用户角色：</td>
					<td><select class="select-pub"  name="roleId"  id="mySelect"  >
						 <option>请选择</option>
					</select></td>
				</tr>
				<tr>
					<td align="right">备注：</td>
					<td><textarea class="textarea-pub"  name="userRemark"></textarea></td>
				</tr>
			</table>
		</form>
	</div>
</body>
<script th:inline="javascript">  
/*<![CDATA[*/  
  function verifyNull(obj){
	
		if(obj == null||obj.val()==""||obj.val()=="请选择"){
			top.$.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">输入的内容不能包含空</div></div>', {
				'title':'提示',
	 	         'buttons':['确定']
		     });
			return false;
		}
	return true;
}      
 function getData(){
	if(!verifyNull($("#mySelect"))){
 		return false;
 	}
	return true;
 }
        
//加载角色
$(function() { 
$.ajax({
    type: 'GET',
    url: '/Role/Roles?timestamp='+new Date().getTime(),
    success: function (data) {
        var data = eval(data);
        var proOPts = "";
        $.each(data, function (i) {
            proOPts += "<option value='" + data[i].id+ "'>" + data[i].roleName + "</option>";
        });
        $("#mySelect").append(proOPts);
        var user = [[${user}]];  
        if(user!=null){
            loadData(user);
        }
    }
}); 
});

  
    
/*]]>*/  
</script>

<script language="javascript" type="text/javascript">  
$(function() { 
$('#mySelect').change(function(){  
$("input[name='roleName']").val($(this).children('option:selected').text());
}); 
});
</script>  

</html>
